package com.dmooo.yxmmerchant.view.model;

import android.content.Context;

import com.common.net.entity.SubjectPost;
import com.common.net.listener.HttpOnNextListener;
import com.common.net.subscribers.ProgressSubscriber;
import com.common.util.LogUtil;
import com.dmooo.yxmmerchant.http.HttpManager;
import com.dmooo.yxmmerchant.view.contract.LoginContract;

import java.util.HashMap;
import java.util.Map;

public class LoginModel implements LoginContract.LoginMdl {
    private Context context;
    public LoginModel(Context context) {
        this.context=context;
    }
    @Override
    public void doLogin(String account, String pwd, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("account",account);
        map.put("pwd",pwd);
        map.put("login_type","android");
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().userLogin(post);
    }

    @Override
    public void doLoginAdmin(String name, String account, String pwd, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("account",name.replaceAll("\"",""));//商户信息
        map.put("merchant_name",account);//登录账号
        map.put("pwd",pwd); //密码
        LogUtil.d("sdfasdf",map.toString());
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().loginAdmin(post);
    }
}
